// 首页mock数据
export const homeData = {
  // 顶部功能卡片数据
  topCards: [
    {
      id: 'recharge',
      title: '充值缴费',
      icon: 'el-icon-bank-card',
      color: '#409EFF',
      route: '/finance/recharge'
    },
    {
      id: 'account',
      title: '一键开户',
      icon: 'el-icon-user-solid',
      color: '#409EFF',
      route: '/tenant/account'
    },
    {
      id: 'bill',
      title: '账单查询',
      icon: 'el-icon-document',
      color: '#409EFF',
      route: '/finance/records'
    },
    {
      id: 'electric',
      title: '电表管理',
      icon: 'el-icon-data-line',
      color: '#409EFF',
      route: '/device/electric'
    },
    {
      id: 'water',
      title: '水表管理',
      icon: 'el-icon-data-analysis',
      color: '#409EFF',
      route: '/device/water'
    },
    {
      id: 'power',
      title: '保电管理',
      icon: 'el-icon-setting',
      color: '#409EFF',
      route: '/power/management'
    }
  ],

  // 费用来源统计数据
  costSourceStats: {
    title: '费用来源',
    totalAmount: 16112.90,
    data: [
      { name: '聚合', value: 0.00, percent: 0.00, color: '#9966CC' },
      { name: '微信', value: 0.00, percent: 0.00, color: '#00CED1' },
      { name: '支付宝', value: 0.00, percent: 0.00, color: '#FF8C00' },
      { name: '现金', value: 16112.90, percent: 100.00, color: '#409EFF' },
      { name: '银联', value: 0.00, percent: 0.00, color: '#00CED1' }
    ]
  },

  // 费用类型统计数据
  costTypeStats: {
    title: '费用类型',
    totalAmount: 16112.90,
    data: [
      { name: '预存', value: 19327.00, color: '#FF8C00' },
      { name: '退费', value: 19327.00, color: '#409EFF' }
    ]
  },

  // 租户数据表格
  tenantTableData: [
    {
      sequence: 1,
      customerName: '李子明',
      totalAmount: 36.00,
      prepaidAmount: 30.00,
      freeAmount: 20.00,
      updateTime: '2025-05-02 15:30:00',
      status: '是'
    },
    {
      sequence: 2,
      customerName: '王小红',
      totalAmount: 45.50,
      prepaidAmount: 40.00,
      freeAmount: 15.00,
      updateTime: '2025-05-02 14:20:00',
      status: '否'
    },
    {
      sequence: 3,
      customerName: '张三丰',
      totalAmount: 28.75,
      prepaidAmount: 25.00,
      freeAmount: 10.00,
      updateTime: '2025-05-02 13:15:00',
      status: '是'
    },
    {
      sequence: 4,
      customerName: '刘德华',
      totalAmount: 52.30,
      prepaidAmount: 50.00,
      freeAmount: 25.00,
      updateTime: '2025-05-02 12:45:00',
      status: '否'
    },
    {
      sequence: 5,
      customerName: '陈小春',
      totalAmount: 33.60,
      prepaidAmount: 30.00,
      freeAmount: 18.00,
      updateTime: '2025-05-02 11:30:00',
      status: '是'
    },
    {
      sequence: 6,
      customerName: '周星驰',
      totalAmount: 41.20,
      prepaidAmount: 35.00,
      freeAmount: 22.00,
      updateTime: '2025-05-02 10:15:00',
      status: '否'
    },
    {
      sequence: 7,
      customerName: '成龙',
      totalAmount: 29.80,
      prepaidAmount: 28.00,
      freeAmount: 12.00,
      updateTime: '2025-05-02 09:45:00',
      status: '是'
    },
    {
      sequence: 8,
      customerName: '李连杰',
      totalAmount: 38.90,
      prepaidAmount: 32.00,
      freeAmount: 16.00,
      updateTime: '2025-05-02 08:30:00',
      status: '否'
    },
    {
      sequence: 9,
      customerName: '甄子丹',
      totalAmount: 46.70,
      prepaidAmount: 42.00,
      freeAmount: 20.00,
      updateTime: '2025-05-02 07:20:00',
      status: '是'
    },
    {
      sequence: 10,
      customerName: '吴京',
      totalAmount: 35.40,
      prepaidAmount: 30.00,
      freeAmount: 14.00,
      updateTime: '2025-05-02 06:15:00',
      status: '否'
    }
  ],

  // 设备统计数据
  deviceStats: [
    {
      id: 'gateway',
      name: '采集网关',
      icon: 'el-icon-cpu',
      color: '#409EFF',
      online: 112,
      offline: 4,
      total: 116
    },
    {
      id: '4g_module',
      name: '4G模块',
      icon: 'el-icon-connection',
      color: '#409EFF',
      online: 112,
      offline: 4,
      total: 116
    },
    {
      id: 'electric_meter',
      name: '电表数量',
      icon: 'el-icon-data-line',
      color: '#409EFF',
      online: 112,
      offline: 4,
      total: 116
    },
    {
      id: 'water_meter',
      name: '水表数量',
      icon: 'el-icon-data-analysis',
      color: '#409EFF',
      online: 112,
      offline: 4,
      total: 116
    }
  ]
}

// API接口模拟函数
export const homeApi = {
  // 获取首页概览数据
  getHomeOverview() {
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve({
          code: 0,
          message: 'success',
          data: {
            topCards: homeData.topCards,
            costSourceStats: homeData.costSourceStats,
            costTypeStats: homeData.costTypeStats
          }
        })
      }, 300)
    })
  },

  // 获取租户表格数据
  getTenantTableData(params = {}) {
    return new Promise((resolve) => {
      setTimeout(() => {
        const { page = 1, pageSize = 10 } = params
        const start = (page - 1) * pageSize
        const end = start + pageSize
        const data = homeData.tenantTableData.slice(start, end)
        
        resolve({
          code: 0,
          message: 'success',
          data: {
            list: data,
            total: homeData.tenantTableData.length,
            page,
            pageSize
          }
        })
      }, 200)
    })
  },

  // 获取设备统计数据
  getDeviceStats() {
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve({
          code: 0,
          message: 'success',
          data: homeData.deviceStats
        })
      }, 150)
    })
  },

  // 获取费用统计数据
  getCostStats(params = {}) {
    return new Promise((resolve) => {
      setTimeout(() => {
        const { type = 'source', dateRange = '30days' } = params
        
        let data
        if (type === 'source') {
          data = homeData.costSourceStats
        } else {
          data = homeData.costTypeStats
        }
        
        resolve({
          code: 0,
          message: 'success',
          data
        })
      }, 250)
    })
  }
}

export default {
  homeData,
  homeApi
}

